package com.sure.supermarketserver.sell.adjust.impl;

import com.sure.supermarketserver.common.Utils;
import com.sure.supermarketserver.sell.adjust.CargoDto;
import com.sure.supermarketserver.sell.adjust.CargoService;
import com.sure.supermarketserver.sell.adjust.dao.CargoDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
@Transactional
public class CargoServiceImpl implements CargoService {
    @Resource
    private CargoDao cargoDao;

    @Override
    public Map<String, Object> cargoPage(CargoDto dto) {
        Map<String, Object> page = new HashMap<>();
        try {
            page = Utils.getPage(dto, () -> cargoDao.cargoPage(dto));
        }catch (Exception e) {
            throw new RuntimeException("查询商品列表失败！", e);
        }
        return page;
    }

    @Override
    public void updCargo(CargoDto dto) {
        try {
            cargoDao.updateCargo(dto);
        }catch (Exception e) {
            throw new RuntimeException("修改商品信息失败！", e);
        }
    }
}
